home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: Problem with THIS
- Date: 2 Jan 1996 13:50:48 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Distribution: world
- Message-ID: <4cbd7o$kst@dawn.mmm.com>
- References: <4bpdlf$e8d@bigboote.WPI.EDU>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Alexander Schelkin (shura@cs.wpi.edu) wrote:
-
- > I need your help.
-
- > I am writing expression classes. I have the base class Expression
- > and derived classes SumExpression, MultiplicationExpresssion,
- > SquareExpression, etc.
-
- > I would like to have something like that:
-
- > Expression* expr, *expr2;
- > expr = new Expression ("a + b");
- > expr2 = new Expression ("(a+b)**");
-
- One approach would be to use the envelope/letter idiom. The Expression
- class could be a container that holds a pointer to the "real" expression
- object. Using this approach you might end up with one class hierarchy
- for the expressions and a single class for the envelope. I could see
- an expression base class with a virtual "evaluate" member, a derivative
- "UnaryExpression" and a derivative "BinaryExpression," etc.
-
- Another idea would be to separate the parsing of expressions from the
- expressions altogether. Then instead of having an envelope class you
- could just write a stand-alone function that would parse a string and
- return an Expression pointer.
-
- > Please send your messages to shura@cs.wpi.edu
-
- People read your question because it was of interest. They deserve to
- see responses. Unless you promise to post a summary of responses, you'll
- have to read mine here.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-